export const appName = "后台管理";

export const tableColumnMinWidth = "135";

export const codingPattern = /^[A-Za-z0-9]+$/;

export const transferPageAll = 10000;

export const uploadApi = "/v1/tool/attachment";

export const telPattern = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;

export const serverUrl = location.origin;

export const loadingText = "拼命加载中";

export const verifyCodeUrl = "/api/lg/validImg?time=";

export const apiPathHeader = "";

/**
 * 选中菜单获取父级菜单name/path
 * @param menuList
 * @param toPath
 * @param tempArray
 * @param fat
 * @returns {*}
 */
export function checkMenuToBreadCrumb(menuList, toPath, tempArray, fat) {
  const tempObj = {};
  for (let i = 0; i < menuList.length; i++) {
    if (toPath === menuList[i].path) {
      if (fat.hasOwnProperty("name")) {
        tempArray.push(fat);
      }
      tempArray.push({
        name: menuList[i].name,
        path: menuList[i].path
      });
      return {
        result: 1,
        breadCrumbList: tempArray
      };
    } else {
      if (menuList[i].children.length !== 0) {
        if (fat.hasOwnProperty("name")) {
          tempArray.push(fat);
        }
        tempObj.name = menuList[i].name;
        tempObj.path = menuList[i].path;
        const temp = checkMenuToBreadCrumb(menuList[i].children, toPath, tempArray, tempObj);
        if (temp.result === 1) {
          return temp;
        }
      } else {
        continue;
      }
    }
    tempArray = [];
  }
  return {
    result: 0,
    breadCrumbList: tempArray
  };
}
